package org.upt.dcda.db;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * The persistent class for the authors database table.
 * 
 */
@Entity
@Table(name = "authors")
@NamedQuery(name = AuthorEntity.VIEW_ALL_AUTHORS, query = "SELECT authorm FROM AuthorEntity authorm")
public class AuthorEntity implements Serializable
{

	public static final String	VIEW_ALL_AUTHORS	= "view_all_authors";

	private static final long	serialVersionUID	= 1L;
	private int					authorId;
	private String				authorInfo;
	private String				authorName;
	private Set<BookEntity>		books;

	public AuthorEntity()
	{
	}

	public AuthorEntity(String authorName, String authorInfo)
	{
		this.setAuthorName(authorName);
		this.setAuthorInfo(authorInfo);
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "author_id")
	public int getAuthorId()
	{
		return this.authorId;
	}

	public void setAuthorId(int authorId)
	{
		this.authorId = authorId;
	}

	@Column(name = "author_info")
	public String getAuthorInfo()
	{
		return this.authorInfo;
	}

	public void setAuthorInfo(String authorInfo)
	{
		this.authorInfo = authorInfo;
	}

	@Column(name = "author_name")
	public String getAuthorName()
	{
		return this.authorName;
	}

	public void setAuthorName(String authorName)
	{
		this.authorName = authorName;
	}

	// bi-directional many-to-one association to BookEntity
	@OneToMany(mappedBy = "author")
	public Set<BookEntity> getBooks()
	{
		return this.books;
	}

	public void setBooks(Set<BookEntity> books)
	{
		this.books = books;
	}

}